package cn.hzking.gjmall.adpters.home;

import android.app.Activity;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import cn.hzking.gjmall.R;
import cn.hzking.gjmall.app.Gjmall;
import cn.hzking.gjmall.bean.HomeDataBean;
import cn.hzking.gjmall.utils.OnClickEvent;
import cn.hzking.gjmall.utils.UIUtils;
import cn.hzking.gjmall.utils.UriMatch;
import cn.hzking.gjmall.view.DashView;

/**主页商品列表第二级布局
 * Created by Administrator on 2018/2/7.
 */

public class SecondTypeChlidAdapter extends BaseQuickAdapter<HomeDataBean.DataBean.TemplateBean.StyleListBean,BaseViewHolder> {
    public SecondTypeChlidAdapter(int layoutResId, @Nullable List<HomeDataBean.DataBean.TemplateBean.StyleListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(final BaseViewHolder baseViewHolder, final HomeDataBean.DataBean.TemplateBean.StyleListBean styleListBean) {
        baseViewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //todo 第二种样式的二级列表
                UIUtils.showToast(mContext,"第二种样式的二级列表"+baseViewHolder.getLayoutPosition(), Toast.LENGTH_SHORT);
            }
        });
        ImageView imageView = baseViewHolder.getView(R.id.two_child_image);
        DashView dashView = baseViewHolder.getView(R.id.two_child_line);
        Glide.with(mContext).load(Gjmall.getOssHost()+styleListBean.getImgUrl()).into(imageView);
        if(baseViewHolder.getLayoutPosition() == getItemCount()-1){
            dashView.setVisibility(View.INVISIBLE);
        }else {
            dashView.setVisibility(View.VISIBLE);
        }
        imageView.setOnClickListener(new OnClickEvent() {
            @Override
            public void singleClick(View v) {
                new UriMatch((Activity) mContext,styleListBean.getUrl()).match();
            }
        });

    }
}
